package sparkcore.day7.lesson04

/**
  * Created by Administrator on 2018/5/2.
  */
case class ApacheLog(ipAddress:String,//Ip地址
                      client:String,//客户端的标识符
                      userID:String,//user ID
                      dateTime:String,//访问时间
                      method:String,//请求方式
                      endPoint:String,//目标地址
                      protocal:String,//请求协议
                      resposeCode:Int,//响应类型
                      contentSize:Double//网页内容大小
 )

object ApacheLog{
  def parseLog(line:String):ApacheLog={
    val fields = line.split("\\#")
    val url = fields(4).split(" ")
    ApacheLog(fields(0),fields(1),fields(2),fields(3),
      url(0),url(1),url(2),
      fields(5).toInt,fields(6).toDouble
    )
  }
}
